import 'package:trip_app/model/home_model.dart';
import 'dart:async';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:trip_app/model/search_model.dart';
const HOME_URL='http://www.devio.org/io/flutter_app/json/home_page.json';

class SearchDao{
  static Future<SearchModel> fetch(String url,String text) async{
    final response= await http.get(url);
    print(response);
    if(response.statusCode ==200){
      Utf8Decoder utf8decoder=Utf8Decoder();
      var result=json.decode(utf8decoder.convert(response.bodyBytes));
      SearchModel model =SearchModel.fromJson(result);
      model.keyword=text;
      return model;
    }else{
      throw Exception('Failed to load home_page.json');
    }
  }
}